package control;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.FacilityDTO;
import business.FacilityManager;


public class DeleteFacilityServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public DeleteFacilityServlet()
	{
		super();
	}
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
	private void doProcess(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		int id = Integer.parseInt(request.getParameter("facilityID"));
		FacilityManager fm = new FacilityManager();
		FacilityDTO facility = fm.findFacility(id);
		fm.deleteFacility(facility);
		RequestDispatcher rd = request.getRequestDispatcher("/LoadFacility");
		rd.forward(request, response);
	}
	}

